package com.example.security.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class TestController {

    @PostMapping(value = "/hello")
    public ResponseEntity<String> hello() throws IOException {
        return ResponseEntity.ok("hello");
    }

    @PostMapping(value = "/permsDel")
    @PreAuthorize("hasAuthority('sys:menu:del')")
    public ResponseEntity<String> permsDel() throws IOException {
        return ResponseEntity.ok("del");
    }

    @PostMapping(value = "/permsEdit")
    @PreAuthorize("hasAuthority('sys:menu:edit')")
    public ResponseEntity<String> permsEdit() throws IOException {
        return ResponseEntity.ok("edit");
    }

}
